<?php
/**
* 订单模块Api Controller
*
* 订单模块Api Controller的注意及说明
* 以下use模块请不要互相伤害
*
* @author    xiecz <xiecz@yunys.com.cn>
* @copyright 2016 QuanZhouYunYiShang Inc.
*/
namespace App\Http\Controllers\Api\Order;
use App\Http\Controllers\Controller;
use Request, Response;
use App\Services\Order\OrderApi;
use App\Services\Order\AfterApi;

class OrderController extends Controller{

    function __construct(OrderApi $orderApi,
                         AfterApi $afterApi){
        $this->orderApi = $orderApi;
        $this->afterApi = $afterApi;
        $this->middleware('transaction',['only'=>['createOrderByShopCar',
                                                  'createOrderByBuyImmediately',
                                                  'orderCancel',
                                                  'orderSign',
                                                  'submitAftermark',
                                                  'submitOrderAftermarkExpress',
                                                  'orderAftermarkSign']]);
    }

    //生成订单√
    function createOrderByShopCar(){
        $input  = Request::all();
        $result = $this->orderApi->create_order_by_shop_car($input);
        return response()->json($result);
    }

    //立即购买生成订单√
    function createOrderByBuyImmediately(){
        $input  = Request::all();
        $result = $this->orderApi->create_order_by_buy_immediately($input);
        return response()->json($result);
    }

    //立即购买活动
    function createOrderByBuyImmediatelyActive(){
        $input  = Request::all();
        $result = $this->orderApi->create_order_by_buy_immediately_active($input);
        return response()->json($result);
    }

    //全部列表√
    function userOrderAll(){
        $input  = Request::all();
        $result = $this->orderApi->user_order_all($input);
        return response()->json($result);
    }

    //待支付订单√
    function userOrderUnpay(){
        $input  = Request::all();
        $result = $this->orderApi->user_order_unpay($input);
        return response()->json($result);
    }

    //待发货列表√
    function userOrderUnsend(){
        $input  = Request::all();
        $result = $this->orderApi->user_order_unsend($input);
        return response()->json($result);
    }

    //待收货列表√
    function userOrderUnsign(){
        $input  = Request::all();
        $result = $this->orderApi->user_order_unsign($input);
        return response()->json($result);
    }

    //已完成√
    function userOrderComplete(){
        $input  = Request::all();
        $result = $this->orderApi->user_order_complete($input);
        return response()->json($result);
    }

    //订单详情√
    function orderDetail(){
        $input  = Request::all();
        $result = $this->orderApi->order_detail($input);
        return response()->json($result);
    }

    //取消订单√ *
    function orderCancel(){
        $input  = Request::all();
        $result = $this->orderApi->order_cancel($input);
        return response()->json($result);
    }

    //催发货√
    function orderUrge(){
        $input  = Request::all();
        $result = $this->orderApi->order_urge($input);
        return response()->json($result);
    }

    //查看订单物流√
    function orderExpressDetail(){
        $input  = Request::all();
        $result = $this->orderApi->order_express_detail($input);
        return response()->json($result);
    }

    //确认收货√
    function orderSign(){
        $input  = Request::all();
        $result = $this->orderApi->order_sign($input);
        return response()->json($result);
    }

    //删除订单
    function orderDelete(){
        $input  = Request::all();
        $result = $this->orderApi->order_delete($input);
        return response()->json($result);
    }

    //修改订单工单号
    function orderWorkSheet(){
        $input  = Request::all();
        $result = $this->orderApi->orderWorkSheet($input);
        return response()->json($result);
    }

    /**
        售后
     */
    //申请售后√
    function submitAftermark(){
        $input  = Request::all();
        $result = $this->afterApi->submit_aftermark($input);
        return response()->json($result);
    }

    //售后列表√
    function userOrderAftermark(){
        $input  = Request::all();
        $result = $this->afterApi->user_order_aftermark($input);
        return response()->json($result);
    }

    //填写退回物流√
    function submitOrderAftermarkExpress(){
        $input  = Request::all();
        $result = $this->afterApi->submit_order_aftermark_express($input);
        return response()->json($result);
    }

    //物流公司列表√
    function getExpressCompany(){
        $input  = Request::all();
        $result = $this->afterApi->get_express_list($input);
        return response()->json($result);
    }

    //售后单详情
    function getAftermarkDetail(){
        $input  = Request::all();
        $result = $this->afterApi->get_aftermark_detail($input);
        return response()->json($result);
    }

    //售后单查看物流信息
    function orderAftermarkExpressDetail(){
        $input  = Request::all();
        $result = $this->afterApi->order_aftermark_express_detail($input);
        return response()->json($result);
    }

    //售后单确认收货
    function orderAftermarkSign(){
        $input  = Request::all();
        $result = $this->afterApi->order_aftermark_sign($input);
        return response()->json($result);
    }

    /**
        物流
     */

    //物流订阅回调
    function postExpressnotify(){
        $input  = Request::all();
        $result = $this->orderApi->expressNotify($input);
        return $result;
    }

    function test(){
        $input  = Request::all();
        $result = $this->orderApi->test($input);
        return response()->json($result);

        echo 'alskdfjalsjfd';
    }
}
